const postcss = require('postcss');
const Tokenizer = require('css-selector-tokenizer');

let options = {
    importItems:[],
    urlItems:[]
};

postcss([createPlugin(options)]).process(css).then(result=>{
    let importJs = options.importItems.map(imp=>{
        return '"+require("'+imp+'")+"';
    }).join('\n');
    let cssString = result.css;
    cssString = cssString.replace(/@import\s+?['"][^'"]+?['"]/,"");
     //url('_CSS_URL_0_') ./avatar.jpg
    cssString = cssString.replace(/_CSS_URL_(\d+?)_/g,function(matched,group1){
        let imageUrl = options.urlItems[+group1];
        return '"+require("'+imageUrl+'")+';
    });
    console.log(importJs+cssString);
});